extends Camera3D

@export var speed := 44.0 
@export var default_fov := 75.0
var is_aiming: bool = false
@onready var target_fov :float = default_fov
func _physics_process(delta: float) -> void:
#region  相机平滑插值
	var weight := clampf(delta * speed,0.0,1.0)
	global_transform = global_transform.interpolate_with(
		get_parent().global_transform,weight
	)
	global_position = get_parent().global_position
#endregion
	if is_aiming:
		fov = lerp(fov,target_fov,delta * 20)


	
func _unhandled_input(event: InputEvent) -> void:
	if event.is_action_released("aim"):
		fov = default_fov
		is_aiming = false
		
func _on_player_aim(multiple: float) -> void:
		is_aiming = true
		target_fov = default_fov * multiple
		print("目标" + str(target_fov))		


